﻿using System;
using System.Windows.Forms;
using EduFormManager.Models.Repo;

namespace EduFormManager
{
    public partial class FormUploadConfirmDialog : Form
    {
        private Boolean isControlsEnabled;

        public FormUploadConfirmDialog(IWin32Window owner, object dataSource)
        {
            InitializeComponent();
            this.comboBoxEdu.DataSource = dataSource;
            this.dateTimePicker1.Value = ((ApplicationRepository)RepositoryFactory.Instance.Repository).GetServerDate();
        }

        private void buttonOk_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        public object SelectedEdu
        {
            set
            {
                this.comboBoxEdu.SelectedItem = value;
            }
            get
            {
                return this.comboBoxEdu.SelectedItem;
            }
        }

        public Boolean ControlsEnabled
        {
            get{
                return isControlsEnabled;
            }
            set
            {
                isControlsEnabled = value;
                this.comboBoxEdu.Enabled = value;
                this.dateTimePicker1.Enabled = value;
            }
        }

        public DateTime SelectedDate
        {
            get
            {
                return this.dateTimePicker1.Value;
            }
        }
    }
}
